package classloader;

import javax.xml.parsers.DocumentBuilderFactory;

import com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl;

public class TestClassLoader {

	/**
	 * @param args
	 * @throws ClassNotFoundException
	 */
	public static void main(String[] args) throws ClassNotFoundException {
		printCL(DocumentBuilderFactoryImpl.class.getClassLoader());
		printCL(DocumentBuilderFactory.class.getClassLoader());
		printCL(ClassLoader.getSystemClassLoader());
		printCL(ClassLoader.getSystemClassLoader().getParent());
		printCL(ClassLoader.getSystemClassLoader().getParent().getParent());

		printCL(Class.forName("classloader.TestClassLoader", true,
				TestClassLoader.class.getClassLoader()).getClassLoader());

		printCL(Class.forName("java.lang.Integer", true,
				TestClassLoader.class.getClassLoader().getParent())
				.getClassLoader());
		printCL(Class.forName("java.lang.String").getClassLoader());
	}

	private static void printCL(ClassLoader classLoader) {
		System.out.println(classLoader == null ? "bootstrap class loader"
				: classLoader);
	}

}
